<!-- 下拉框组件 -->
<template>
    <div>
      <select @change="changs">
        <option v-for="(item,index) in list" :value="item.name">{{item.name}}</option>
      </select>
    </div>
</template>

<script>
export default{
  name:'selects',
  props:{
    msg:{
      type:Number,
      default:'默认值'
    },
  },
  data(){
    return {
      list:[],
      mp:[1,2,4,6,2,6,7,2,1]
    }
  },
  created() {
    if(this.msg==2){
      this.list=[
        {id:1,name:'列表一'},
        {id:2,name:'列表二'}
      ]
    }
  },
  methods:{
    changs(event){
      this.$emit('cc',event.target.value);
    },
    maopao(num){
      for(var i=0;i<=num.length;i++){
        for(var j=0;j<num.length-1-i;j++){
          if(num[j]>num[j+1]){
            // var tem=num[j+1];
            // num[j+1]=num[j];
            // num[j]=tem;
            [num[j+1],num[j]]=[num[j],num[j+1]]
          }
        }
      }
      console.log(num)
      return num
    }
  },
  mounted() {
    console.log('冒泡排序')
    this.maopao(this.mp)
  },
}
</script>

<style>
</style>
